import java.util.Stack;

class MyQueue {
    private Stack<Integer> stack1 = new Stack<>();
    private Stack<Integer> stack2 = new Stack<>();

    public MyQueue() {

    }
    
    public void push(int x) {
       //入队的时候全放在第一个栈当中
        stack1.push(x);
        int sz = stack1.size();
        for(int i =0;i<sz;++i){
            stack2.push(stack1.pop());
        }
    }
    
    public int pop() {
         if(stack2.isEmpty()){
             return -1;
         }
         //把stack1栈中的元素全部放到stack2中去
         int sz = stack1.size();
         for(int i =0;i<sz;++i){
             stack2.push(stack1.pop());
         }
         return stack2.pop();
    }
    
    public int peek() {
         //返回栈顶当中的元素
         if(stack2.isEmpty()){
             return -1;
         }
         return stack2.peek();
    }
    
    public boolean empty() {
         return stack1.isEmpty()&&stack2.isEmpty();
    }

    public static void main(String[] args) {
        MyQueue queue = new MyQueue();
        queue.push(1);
        queue.push(1);
        System.out.println(queue.peek());
        queue.pop();
        queue.empty();

    }
}